/*
 * @Description:
 * @Version: 2.0
 * @Autor: zhaoyu
 * @Date: 2021-04-29 16:18:53
 * @LastEditors: zhaoyu
 * @param:
 * @return:
 * @author: zhaoyu
 */

import React, { useRef, useEffect } from "react";
import styles from "./index.m.less";

const Search = () => {
  const textRef = useRef();

  useEffect(() => {
    textRef.current.focus();
  }, []);

  const baidu = () => {
    window.open("https://www.baidu.com/s?wd=" + textRef.current.value);
  };

  return (
    <div className={styles.search}>
      <div className={styles.box}>
        <input ref={textRef} type="text" placeholder="搜索你不知道的？" />
        <button className={styles.btn} onClick={baidu} type="button">
          百度一下
        </button>
      </div>
    </div>
  );
};

export default Search;
